import onnx
import warnings
import numpy as np
import onnxruntime as ort
from onnx_tf.backend import prepare
import torch
from torch import nn


if __name__ == "__main__":
    model_path = "../onnx_models/pytorch/torch.reciprocal.onnx"
    # ignore all the warnings
    warnings.filterwarnings("ignore")
    model = onnx.load(model_path)
    tf_rep = prepare(model)
    # x = np.random.randn(3).astype(np.float32)
    x = np.array([-6.6e+307, -1.03e+307, 7.86e+307], dtype=np.float64)
    print("input:" + str(x))

    print("tensorflow output:" + str(tf_rep.run(x)[0]))
    print("pytorch output:" + str(torch.reciprocal(torch.as_tensor(x))))

    ort_session = ort.InferenceSession(model_path)
    outputs = ort_session.run(None, {"input": x})
    print("onnx output:" + str(outputs[0]))
